package com.fjnldx.mes.mapper.common;

import com.fjnldx.mes.domain.domainReq.QueryParamReq;
import com.fjnldx.mes.domain.pojo.QueryParam;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Component;

import java.util.List;
import java.util.Map;

@Component
@Mapper
public interface CommonMapper {
    /**
     * 获得密码
     * @param username
     * @return
     */
    @Select("select password from user where username=#{username} limit 0,1")
    String getPassword(String username);
    @Select("select role from user where username=#{username} limit 0,1")
    String getRole(String username);
    @Select("select uuid from user where username=#{username}")
    String getUserUuid(String username);
    @Select("select uuidKs from user where username=#{username}")
    String getUserUuidKs(String username);
    @Update("UPDATE user set uuid = #{uuid} WHERE username=#{username}")
    void updateUserUuid(String username,String uuid);

    /**
     * 测试
     */
    @Select("SELECT * FROM `fzy_dictionary_data`")
    List<Map<String,Object>> test();


    /**
     * 插入数据字典设备
     */
    @Insert("insert into fzy_dictionary_data_list(key_name,key_value,dic_bh) values(#{key_name},#{key_value},#{dic_bh})")
    int insertEquipment(String key_name,String key_value,String dic_bh);


    /**
     * 获取查询使用的参数
     * @param queryParamReq
     * @return
     */
    @Select("select id, type, dict_code dictCode, dict_value dictValue from query_param where type = #{type}")
    List<QueryParam> queryParam(QueryParamReq queryParamReq);
}
